package com.xinzhi.savingpot.userinfo.service.impl;

import com.xinzhi.savingpot.userinfo.service.ISendCode;
import com.xinzhi.savingpot.util.BaseResponse;
import com.xinzhi.savingpot.util.IsMobileUtil;
import com.xinzhi.savingpot.util.NoteUtil;
import com.xinzhi.savingpot.util.RedisUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

@Service
public class SendCodeImpl implements ISendCode {
    @Autowired
    private RedisUtil redisUtil;
    @Autowired
    private IsMobileUtil isMobileUtil;

    @Override
    public BaseResponse sendCode(String phone) {
        if (isMobileUtil.checkCellphone(phone)) {
            String code1 = NoteUtil.VCode();
            NoteUtil.send(phone, code1);
            redisUtil.set(phone, code1, 300);
            return new BaseResponse(100, "发送成功");
        }
            return new BaseResponse(100, "请输入正确的手机号");
    }


}



